..
This file was automatically converted from MediaWiki syntax.
If some markup is wrong, looks weird or doesn't make sense, feel free
to fix it.
Please remove this comment once this file was manually checked
and no "strange ReST" artifacts remain.
.. _how-to-compile-a-cxx-panda3d-program-on-mac-os-x:
How to compile a CXX Panda3D program on Mac OS X
================================================
.. only:: python
This page is related to C++ usage of Panda3D and not to Python usage. If you
are a Python user, please skip this page. For C++ users, please toggle to the
C++ version of this page.
.. only:: cxx
This short guide explains how to build a Panda3D game written in C++ game
under Mac OS.
Mac OS comes with python installed, however because of production cycles your
version may be a bit outdated, if you want to download the latest python
version, you can go to the `Python `__
website. Just make sure that the Panda3D version is compatible with it.
In order to compile you need also to have the GNU G++ compiler. Unlike in
Linux, the G++ compiler is not pre-installed in Mac OS X, you will need to
install Xcode development tools, the installer comes in the Mac OS installer
CDs or DVDs, however for newer versions, you can download it from its
`website `__. You will need to register for an
account.
Having these two components, we can proceed to compile:
First we must create .o file from our cxx file. We need to link to the Panda3D
include files and to the Python include files. Note: only 386 arch is
supported for panda 1.7.0 so we need to include the -arch i386 flag.
.. code-block:: bash
g++ -c filename.cxx -o filename.o -fPIC -O2 -arch i386 -I{pythoninclude} -I{panda3dinclude}
Please change the paths in these commands to the appropiate locations. A list
of locations is at the end of the page.
Secondly, we need to generate an executable, you can use the following
command:
.. code-block:: bash
g++ filename.o -o filename -fPIC -arch i386 -L{panda3dlibs} -lp3framework -lpanda -lpandafx -lpandaexpress -lp3dtoolconfig -lp3dtool -lp3pystub -lp3direct
As mentioned above, we need to change the paths accordingly, the paths for Mac
OS are listed below:
• {pythoninclude}: The path to your Python include folder. For version 2.5,
this is /usr/include/python2.5 by default.
• {panda3dinclude}: Change this to the path to your Panda3D include directory.
This would probably look like /Developer/Panda3D/include/ in the case of
1.7.0. (for 1.6.2 use /Applications/Panda3D/1.6.2/include/)
• {panda3dlibs}: Change this to the path to your Panda3D libraries. This is
/Developer/Panda3D/lib in the case of 1.7.0. (for 1.6.2 use
/Applications/Panda3D/1.6.2/lib/)
And lastly to run the created executable, type:
.. code-block:: bash
./filename
• If you get warnings like "missing required architecture x86\_64 in file" or
"Undefined symbols: "\_main", referenced from:" you need to the -arch i368
flag.
• If you get errors like "Undefined symbols: "TypedObject::\_type\_handle",
referenced from: " you are not including some panda3d libraries needed or
missing the-arch i386 flag.
• If you get an error running your executable like "dyld: Library not loaded:
@executable\_path/../Library/Frameworks/Cg.framework/Cg" means you need to
install Cg library from http://developer.nvidia.com/object/cg_download.html